package com.wewins.fota.bean.bo.excel.data;

import com.wewins.fota.bean.bo.excel.column.ExcelColumn;
import com.wewins.fota.bean.bo.excel.column.ExcelColumnGroup;
import com.wewins.fota.bean.bo.excel.column.FotaLogStatusColumn;
import com.wewins.fota.common.constant.FotaCode;
import com.wewins.fota.bean.bo.excel.*;
import com.wewins.fota.bean.po.FotaLog;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExportFotaLog implements DataSource {
    @ExcelColumnGroup
    private FotaLog fotaLog;

    @ExcelColumn(value = "状态", cellClazz = FotaLogStatusColumn.class)
    private FotaCode status;

    @Override
    public RowData convertColumnData() {
        RowData rowData = fotaLog.convertColumnData();
        ArrayList<Column> columns = new ArrayList<>(rowData.getColumns());
        columns.add(FotaLogStatusColumn.builder().value(this.status).build());
        rowData.setColumns(columns);
        return rowData;
    }
}
